/**
 * May 21, 2014 2:35:11 PM
 */
package elitech.vietnam.copyweatherfashion.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.google.gson.Gson;

import elitech.vietnam.copyweatherfashion.MainActivity;
import elitech.vietnam.copyweatherfashion.entities.Notify;

/**
 * @author Cong
 *
 */
public class UpdateBadgeReceiver extends BroadcastReceiver {
	
	MainActivity mActivity;
	
	public UpdateBadgeReceiver(MainActivity activity) {
		mActivity = activity;
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		mActivity.mBadgeCount += 1;
		Notify mNotify = new Gson().fromJson(intent.getStringExtra(MainActivity.EXTRAS_NOTIFYDATA), Notify.class);
		mActivity.mListNotify.add(0, mNotify);
		mActivity.notifyBadgeChanged();
	}
}
